package st.yushao.restaurant.action.custom;

import java.util.List;

import st.yushao.restaurant.dao.FoodDaoService;
import st.yushao.restaurant.dao.FoodTypeDaoService;
import st.yushao.restaurant.fw.AbstractBaseAction;
import st.yushao.restaurant.vo.FoodTypeVO;

public class GetAllFoodInfo extends AbstractBaseAction {

    /**
     * serialVersionUID
     */
    private static final long serialVersionUID = -3118938164528755583L;

    private FoodTypeDaoService ftds;
    private FoodDaoService fds;
    private List<FoodTypeVO> ftLst;

    @Override
    public String doExecute() {
        ftLst = ftds.getFoodTypeListByRest(getRestId());
        if (ftLst == null || ftLst.isEmpty()) {
            return SUCCESS;
        }
        // get food infomation by food type
        for (FoodTypeVO ftv : ftLst) {
            ftv.setFoodInfos(fds.getFoodListByType(ftv.getId()));
        }
        return SUCCESS;
    }

    /**
     * @param ftds the ftds to set
     */
    public void setFtds(FoodTypeDaoService ftds) {
        this.ftds = ftds;
    }

    /**
     * @param fds the fds to set
     */
    public void setFds(FoodDaoService fds) {
        this.fds = fds;
    }

    /**
     * @return the ftLst
     */
    public List<FoodTypeVO> getFtLst() {
        return ftLst;
    }
}
